/*
 +----------------------------------------------------------------------
 + Title        : groupChat
 + Author       : huwl
 + Version      : 1.0.0
 + Initial-Time : 2024-12-11
 + Last-time    : 这个文件最后修改的时间 + 修改人的名称
 + Desc         : 群聊接口
 +----------------------------------------------------------------------
*/

import { DisturbParams, TopParams } from "@/types/friend"
import type { ApiResponse } from "@/types/global"
import type { CreateGroupChatParams, EditGroupChatParams, GroupChatListParams, GroupChatListResult, GroupChatTotalResult, JoinGroupChatParams, RemoveMemberParams, TransferAdminParams } from "@/types/groupChat"
import request from '@/utils/httpRequest'


/**
 * 创建,请求方式[POST]
 * 
 * @param CreateGroupChatParams data ----------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqCreateGroupChatAPI = (data: CreateGroupChatParams) => {
    return request<any, ApiResponse<any>>({
        method: 'POST',
        url: 'groupChat/create',
        data
    })
}

/**
 * 加入,请求方式[POST]
 * 
 * @param JoinGroupChatParams data -----------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqJoinGroupChatAPI = (data: JoinGroupChatParams) => {
    return request<any, ApiResponse<any>>({
        method: 'POST',
        url: 'groupChat/join',
        data
    })
}

/**
 * 删除,请求方式[GET]
 * 
 * @param string ids -------------------------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqDeleteGroupChatAPI = (ids: string) => {
    return request<any, ApiResponse<any>>({
        method: 'GET',
        url: 'groupChat/delete',
        params: {ids}
    })
}

/**
 * 移除成员,请求方式[GET]
 * 
 * @param RemoveMemberParams data ------------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqRemoveMemberAPI = (params: RemoveMemberParams) => {
    return request<any, ApiResponse<any>>({
        method: 'GET',
        url: 'groupChat/removeMember',
        params
    })
}

/**
 * 编辑,请求方式[POST]
 * 
 * @param EditGroupChatParams data -----------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqEditGroupChatAPI = (data: EditGroupChatParams) => {
    return request<any, ApiResponse<any>>({
        method: 'POST',
        url: 'groupChat/edit',
        data
    })
}

/**
 * 详情,请求方式[GET]
 * 
 * @param number id --------------------------------------------群Id
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqGroupChatDetailAPI = (id: number) => {
    return request<any, ApiResponse<any>>({
        method: 'GET',
        url: 'groupChat/detail',
        params: {id}
    })
}

/**
 * 列表,请求方式[GET]
 * 
 * @param GroupChatListParams params ---------------------------请求参数
 * @returns <any, ApiResponse<GroupChatListResult>>
 * @author huwl
 */
export const reqGroupChatListAPI = (params: GroupChatListParams) => {
    return request<any, ApiResponse<GroupChatListResult>>({
        method: 'GET',
        url: 'groupChat/list',
        params
    })
}

/**
 * 数量,请求方式[GET]
 * 
 * @param GroupChatListParams params ---------------------------请求参数
 * @returns <any, ApiResponse<GroupChatTotalResult>>
 * @author huwl
 */
export const reqGroupChatTotalAPI = (params: GroupChatListParams) => {
    return request<any, ApiResponse<GroupChatTotalResult>>({
        method: 'GET',
        url: 'groupChat/total',
        params
    })
}

/**
 * 转让管理员,请求方式[POST]
 * 
 * @param TransferAdminParams data -----------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqTransferAdminAPI = (data: TransferAdminParams) => {
    return request<any, ApiResponse<any>>({
        method: 'POST',
        url: 'groupChat/transferAdmin',
        data
    })
}

/**
 * 解散群聊,请求方式[POST]
 * 
 * @param number gid -------------------------------------------群Id
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqDissolveAPI = (gid: number) => {
    return request<any, ApiResponse<any>>({
        method: 'POST',
        url: 'groupChat/dissolve',
        data: {gid}
    })
}

/**
 * 免打扰,请求方式[GET]
 * 
 * @param DisturbParams params ---------------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqGroupChatDisturbAPI = (params: DisturbParams) => {
    return request<any, ApiResponse<any>>({
        method: 'GET',
        url: 'groupChat/disturb',
        params
    })
}

/**
 * 置顶,请求方式[GET]
 * 
 * @param TopParams params -------------------------------------请求参数
 * @returns <any, ApiResponse<any>>
 * @author huwl
 */
export const reqGroupChatTopAPI = (params: TopParams) => {
    return request<any, ApiResponse<any>>({
        method: 'GET',
        url: 'groupChat/top',
        params
    })
}